// ignore_for_file: dangling_library_doc_comments, slash_for_doc_comments
import 'package:get/get_connect.dart';
import 'package:wan_android_flutter/common_code/wrapper/dio_wrapper/dio_client.dart';
import 'package:wan_android_flutter/module_code/home/models/home_article_list_model.dart';

import '../models/home_banner_model.dart';
import '../models/home_tab_classify_model.dart';
import '../models/home_tab_list_model.dart';

/*** 
 * @Author: Zhong
 * @Date: 2025-03-21 09:18:51
 * @LastEditors: Zhong zhongxiaodong@eenet.com
 * @LastEditTime: 2025-08-13 17:40:42
 * @FilePath: /wan_android_flutter/lib/module_code/home/api/home_api.dart
 * @Description: 
 */
class HomeApi {
  // 获取首页轮播图接口
  static Future<List<HomeBannerDataModel>?> getHomeBanner() async {
    var response = await DioClient.get("/banner/json");
    HomeBannerModel model = HomeBannerModel.fromJson(response.data);
    if (model.errorCode == 0) {
      return model.data;
    }
    return null;
  }

  // 获取首页文章列表接口
  static Future<HomeArticleListDataModel?> getHomeArticleList({
    int pageNum = 1,
  }) async {
    var response = await DioClient.get("/article/list/$pageNum/json");
    HomeArticleListModel model = HomeArticleListModel.fromJson(response.data);
    if (model.errorCode == 0) {
      return model.data;
    }
    return null;
  }

  // 获取首页tab分类接口
  static Future<List<HomeTabClassifyDataModel>?> getHomeTabData() async {
    var response = await DioClient.get("/project/tree/json");
    HomeTabClassifyModel model = HomeTabClassifyModel.fromJson(response.data);
    if (model.errorCode == 0) {
      return model.data;
    }
    return null;
  }

  // 获取首页tab里的列表接口
  static Future<List<HomeTabListDataDataModel>?> getHomeTabListData({
    int pageNum = 1, required int cid,
  }) async {
    var response = await DioClient.get("/project/list/$pageNum/json?cid=$cid");
    HomeTabListModel model = HomeTabListModel.fromJson(response.data);
    if (model.errorCode == 0) {
      return model.data?.datas;
    }
    return null;
  }
}
